<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :append-to-body="true" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">学生公立校成绩添加</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="学生名称">
				 <el-input v-model="vxsmc" :readonly='true' placeholder="请输入学生成绩" icon="add" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="学生成绩">
				 <el-input v-model="vcj" type="number" placeholder="请输入学生成绩" icon="add" class="select-block"></el-input>
			</el-form-item>
            <el-form-item label="成绩类型">
				 <el-input v-model="vlx" placeholder="请输入成绩类型" icon="add" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="排名">
				 <el-input v-model="vpm" type="number" placeholder="请输入排名" icon="add" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="附件1">
				 <el-input v-model="vfj1" placeholder="请输入" icon="add" class="select-block"></el-input>
			</el-form-item>
		</el-form>
		<el-button type="primary" class="submit" @click="submit">添加</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
			props: ['params'],
		data() {
			return {
				vxsmc:'',
				vbjid:'',
				vxsid: '',
				vcj: '',
				vlx: '',
				vpm: '',
				vfj1: '',
				dialogTableVisible: true,
			}
		},
		created () {
			
			this.vxsid=this.params.id;
			this.vxsmc=this.params.zwm;
		},
		methods: {
			submit() {
			  this.$store.state.loading = true;
				if(!this.vcj){
					this.$message.warning('请填写学生成绩');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vlx){
					this.$message.warning('请选择类型');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vpm){
					this.$message.warning('请填写排名');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xsid: this.vxsid,
					cj: this.vcj,
					lx:this.vlx,
					pm: this.vpm,
					fj1:this.vfj1,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xsxwcj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'glxcj', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'glxcj', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
							this.$message.warning("服务器繁忙，请重试");
							//this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'glxcj', cancel: true })
			}
		}
	}
</script>
<style lang="less">
.wrap {
	text-align: center;
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}

.select-block {
	display: block;
	width: 85%;
}

.submit {
	width: 120px;
}
.el-form-item {
    margin-bottom: 10px;
}
</style>
